package com.appwoo.txtws.component;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESedeKeySpec;
import javax.crypto.spec.IvParameterSpec;

public class CrypHelper
{
  private static String m_strIv = "123ABC4D";
  private static String m_strKey = "txtws@1234567890abcdefgh";

  public static String decodeString(String paramString, int paramInt)
  {
    String str = paramString;
    if (isNumeric(str))
      str = Long.valueOf(Long.valueOf(158888L + Long.valueOf(Long.parseLong(paramString)).longValue()).longValue() / paramInt).toString();
    return str;
  }

  public static byte[] des3DecodeCBC(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2, byte[] paramArrayOfByte3)
    throws Exception
  {
    DESedeKeySpec localDESedeKeySpec = new DESedeKeySpec(paramArrayOfByte1);
    SecretKey localSecretKey = SecretKeyFactory.getInstance("desede").generateSecret(localDESedeKeySpec);
    Cipher localCipher = Cipher.getInstance("desede/CBC/PKCS5Padding");
    localCipher.init(2, localSecretKey, new IvParameterSpec(paramArrayOfByte2));
    return localCipher.doFinal(paramArrayOfByte3);
  }

  public static String des3DedoceCBCString(String paramString)
    throws Exception
  {
    return new String(des3DecodeCBC(m_strKey.getBytes("UTF-8"), m_strIv.getBytes("UTF-8"), Base64Helper.decode(paramString, 0)), "UTF-8");
  }

  public static byte[] des3EncodeCBC(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2, byte[] paramArrayOfByte3)
    throws Exception
  {
    DESedeKeySpec localDESedeKeySpec = new DESedeKeySpec(paramArrayOfByte1);
    SecretKey localSecretKey = SecretKeyFactory.getInstance("desede").generateSecret(localDESedeKeySpec);
    Cipher localCipher = Cipher.getInstance("desede/CBC/PKCS5Padding");
    localCipher.init(1, localSecretKey, new IvParameterSpec(paramArrayOfByte2));
    return localCipher.doFinal(paramArrayOfByte3);
  }

  public static byte[] des3EncodeECB(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2)
    throws Exception
  {
    DESedeKeySpec localDESedeKeySpec = new DESedeKeySpec(paramArrayOfByte1);
    SecretKey localSecretKey = SecretKeyFactory.getInstance("desede").generateSecret(localDESedeKeySpec);
    Cipher localCipher = Cipher.getInstance("desede/ECB/PKCS5Padding");
    localCipher.init(1, localSecretKey);
    return localCipher.doFinal(paramArrayOfByte2);
  }

  public static String des3EndoceCBCString(String paramString)
    throws Exception
  {
    return new String(Base64Helper.encode(des3EncodeCBC(m_strKey.getBytes("UTF-8"), m_strIv.getBytes("UTF-8"), paramString.getBytes("UTF-8")), 0), "UTF-8");
  }

  public static byte[] ees3DecodeECB(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2)
    throws Exception
  {
    DESedeKeySpec localDESedeKeySpec = new DESedeKeySpec(paramArrayOfByte1);
    SecretKey localSecretKey = SecretKeyFactory.getInstance("desede").generateSecret(localDESedeKeySpec);
    Cipher localCipher = Cipher.getInstance("desede/ECB/PKCS5Padding");
    localCipher.init(2, localSecretKey);
    return localCipher.doFinal(paramArrayOfByte2);
  }

  public static String encodeString(String paramString, int paramInt)
  {
    String str = paramString;
    if (isNumeric(str))
      str = Long.valueOf(Long.valueOf(Long.valueOf(Long.parseLong(str)).longValue() * paramInt).longValue() - 158888L).toString();
    return str;
  }

  public static String getDateAndTime()
  {
    return new SimpleDateFormat("yyyyMMddHHmmss").format(new Date(System.currentTimeMillis()));
  }

  public static boolean isNumeric(String paramString)
  {
    return Pattern.compile("[0-9]*").matcher(paramString).matches();
  }

  public static String nDecodeString()
  {
    try
    {
      String str1 = 18 * (3 * Integer.parseInt(getDateAndTime().substring(2, 10)) - 158888);
      String str2 = str1.substring(-6 + str1.length(), str1.length());
      return str2;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
    return "00000000";
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.component.CrypHelper
 * JD-Core Version:    0.6.2
 */